from flask import Flask, request, jsonify
from rag_service import RAGService

app = Flask(__name__)
rag_service = RAGService()

# Sample documents for demonstration
documents = [
    "Python is a high-level programming language.",
    "Flask is a micro web framework written in Python.",
    "FAISS is a library for efficient similarity search and clustering of dense vectors.",
    "Sentence Transformers provides pre-trained models for text embeddings."
]

rag_service.embed_documents(documents)

@app.route('/search', methods=['POST'])
def search():
    data = request.json
    query = data.get('query', '')
    top_k = data.get('top_k', 5)
    results = rag_service.search(query, top_k)
    return jsonify(results)

if __name__ == '__main__':
    app.run(debug=True)